package com.cutthroatcreations.woodenrailway;

import java.util.ArrayList;

import com.cutthroatcreations.woodenrailway.Train.Year;
import com.cutthroatcreations.woodenrailway.ImageHandler.*;
import android.app.Application;
import android.content.Context;
import android.util.Log;

public class WoodenApplication extends Application {
	private static final String TAG = "WoodenApplication";
	private static WoodenApplication instance;
	private static int yearIndex = 0;
	public static ArrayList<Train> allTrains = null;
	public static User user = null;
	public static String[] cCategories;
	public static String[] cYears;
	public boolean logged;

	public WoodenApplication() {

		instance = this;
		logged = false;

	}

	@Override
	public void onCreate() {
		super.onCreate();
		cCategories = new String[] { "Engines", "Rolling Stock",
				"Track Systems", "Destinations", "Accessories", "Value Sets" };
		cYears = new String[] { "All Items", "1992/1993", "1994", "1995",
				"1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003",
				"2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011",
				"2012", "2013" };
	}

	public static void clearCache() {
		FileCache fc = new FileCache(instance);
		fc.clear();
	}

	public static Train getTrainById(int trainId) {
		for (int i = 0; i < WoodenApplication.getAllTrains().size(); i++) {
			if (WoodenApplication.getAllTrains().get(i).getID() == trainId) {
				return WoodenApplication.getAllTrains().get(i);
			}
		}
		return null;

	}
	
	public static void setYearIndex(int index){
		yearIndex = index;
	}
	
	public static int getYearIndex(){
		return yearIndex;
	}


	public static ArrayList<Train> getAllTrains() {
		return allTrains;
	}

	public static Context getContext() {
		return instance;
	}

}